package com.smyx.webbox;

import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author SmyxCoding
 **/
public class MyServer {
    private static final int PORT = 18000;

    public void startServer() {
        try {
            // 创建连接
            ServerSocket serverSocket = new ServerSocket(PORT);
            while (true) {
                // 接收请求
                Socket accept = serverSocket.accept();
                // 获取请求的IO流，利用IO流获取请求数据
                InputStream inputStream = accept.getInputStream();
                byte[] bytes = new byte[1024];
                inputStream.read(bytes);
                // 解析地址
                String string = new String(bytes);
                int i = string.indexOf(" ");
                int i1 = string.indexOf(" ", i + 1);
                String path = string.substring(i + 1, i1);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        new MyServer().startServer();
    }
}
